package com.work.cos.web.controller.api;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.work.cos.domain.entity.FootPrintLogEntity;
import com.work.cos.domain.vo.ComServiceResVo;
import com.work.cos.service.interfc.IFootPrintLogService;

@RestController
@RequestMapping("/api/footprint")
public class FootPrintLogController {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(FootPrintLogController.class);
	
	@Autowired
	private IFootPrintLogService footPrintLogService;
	
	/**
	 * 足迹明细查询
	 * @param userId
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	@PostMapping(value = "/query")
	public ComServiceResVo queryFootPrintLogs(@RequestParam Long userId,@RequestParam int pageNo,
			@RequestParam int pageSize){
		LOGGER.debug("api credits query ... ");
		return ComServiceResVo.returnList(footPrintLogService.
				findFootPrintLogByUserId(userId, pageNo, pageSize).getItems());
	}
	
	/**
	 * 足迹追加
	 * @param entity
	 * @return
	 */
	@PostMapping(value = "/add")
	public ComServiceResVo addFootPrintLog(FootPrintLogEntity entity) {
		footPrintLogService.addFootPrintLog(entity);
		return ComServiceResVo.returnSuccessStatus();
	}
}
